package com.swd.order.controller;

import com.swd.order.model.User;
import com.swd.order.service.UserService;
import com.swd.order.service.WxService;
import com.swd.order.util.WxProperties;
import com.swd.order.util.WxUtil;
import com.swd.order.vo.Ret;
import com.swd.order.vo.Rets;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;


@RequestMapping("wx")
@RestController
@Slf4j
public class WxController {

    @Value("${wx.token}")
    private String wxToken;
    @Autowired
    private WxService wxService;
    @Autowired
    private UserService userService;
    @Autowired
    private WxUtil wxUtil;
    @Autowired
    private WxProperties wxProperties;

    @GetMapping("checkSiginature")
    public ResponseEntity checkSiginature(String signature, String timestamp, String nonce, String echostr) {

        return ResponseEntity.ok(echostr);
    }

    @GetMapping("access_token")
    public Ret getAccessToken(){
        return Rets.success(wxUtil.getAccessToken());
    }




}
